package com.wh1200.mybatis.xmlless.dialect

import com.wh1200.mybatis.xmlless.enums.XmllessDbType
import com.wh1200.mybatis.xmlless.util.DbTypeHolder

/**
 *
 * @author 吴昊
 * @date 2023/12/17 13:28
 * @since v4.0.0
 * @version 1.0
 */
object DialectFactory {

  fun quote(str: String, quote: Boolean): String {
    if (quote) {
      return "\"$str\""
    }
    return str
  }

  fun getDialect(): IDialect {
    return getDialect(DbTypeHolder.getDBType())
  }

  fun getDialect(dialect: XmllessDbType): IDialect {
    return when (dialect) {
      XmllessDbType.POSTGRE_SQL -> PostgreSQLDialect
      else                      -> MySqlDialect
    }
  }

}
